<%-- 
    Document   : movielist
    Created on : Jul 22, 2012, 9:33:36 AM
    Author     : Atienza-Home
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<style type="text/css">
    th{
        border: 2px solid black;
       
        
    }
    
    td{
        
        background-color: #009999;
        text-align: center;
       
    }
    
    
</style>

<link href="../adminpanel/header.css" rel="stylesheet" type="text/css"></link>

<%@page import="java.util.Iterator"%>
<%@page import="Factory.Tables.Movie"%>
<%@page import="java.util.ArrayList"%>

<table width="990px"  >
<tr>
    <th width="14%">Pic</th>
    <th width="25%">Movie</th>
    <th width="12%">Category</th>
    <th width="9%">Created</th>
    <th width="9%">Price</th>
    <th width="10%">Release</th>
    <th width="3%">View</th>
    <th width="3%">Rate</th>
    <th width="5%">Active</th>
    <th width="5%">Edit</th>
    <th width="5%">Delete</th>
    
    


</tr>

<% 
    ArrayList<Movie> result = (ArrayList<Movie>)session.getAttribute("movies");
    Iterator<Movie> iter;
    Movie movie;
    int i;
    if(result!=null){
        iter = result.iterator(); 
        i=0;
        while(iter.hasNext()){
            movie = iter.next();
            
            %>
            <tr>
                <%
                    if(movie.getActive()==1){
                    try{
                    if(!movie.getMoviePic().isEmpty()){
                    %>
                        <td><img alt="noimage" src="../images/movie/<%=movie.getMoviePic()%>" style="width:120px; margin: 0px;"/></td>
                                         
                    <%                                                                                     
                    }}catch(Exception e){
                    %>
                    <td valign="middle"><img alt="noimage" src="../images/movie/movienopic.png"/></td>
                                         
                    <%      
                                       
                    }
                            
                %>
                
                <td valign="middle"><font><%=movie.getName()%></font>
                    <br><a title="Add stock" href="javascript:addQuantity(<%=movie.getId() %>)" ><font color="white">  Quantity:<%=movie.getInventoryQuantity() %></font></a>
                    <div id="addstock<%=movie.getId()%>" style="display: none;">
                        
                        <form action="javascript:addStocktoMovie(<%= movie.getId() %>)" method="get"> 
                            <input id="stockinput" type="number" min="0" step="10" value="0" style="width:50px;"/>
                            <input type="submit" value="Add">
                        </form>
                    
                    </div>
                </td>
                <td valign="middle"><font><%=movie.getCategoryName()%></font></td>
                <td valign="middle"><font><%=movie.getDateActive()%> <%=movie.getTimeActive()%></font></td>
                <td valign="middle"><font>P<%=movie.getPrice()%></font></td>
                <td valign="middle"><font><%=movie.getReleaseDate()%></font></td>
                <td valign="middle"><font><%=movie.getViews()%></font></td>
                <td valign="middle"><font><%=movie.getRating()%></font></td>
                <td valign="middle"><font><%=movie.getActive()%></font></td>
                
                <td valign="middle"><div id="editmovie<%=movie.getId()%>"><font><a href="javascript:gotoEditMovie(<%=movie.getId()%>)">Edit</a></font></div></td>
                <td valign="middle"><div id="deletemovie<%=movie.getId()%>"><font><a href="javascript:deleteMovie(<%=movie.getId()%>)">Delete</a></font></div></td>
               
                
            
            
            
            
            
            
            
            
            <%
                    }else{
                    try{
                    if(!movie.getMoviePic().isEmpty()){
                    %>
                        <td style=" background-color: #cc6666;" ><img alt="noimage" src="../images/movie/<%=movie.getMoviePic()%>" style="width:120px; margin: 0px;"/></td>
                                         
                    <%                                                                                     
                    }}catch(Exception e){
                    %>
                        <td style=" background-color: #cc6666;" valign="middle"><img alt="noimage" src="../images/movie/movienopic.png"/></td>
                                         
                    <%      
                                       
                    }
                            
                %>
                
                <td style=" background-color: #cc6666;" valign="middle"><font><%=movie.getName()%></font></td>
                <td style=" background-color: #cc6666;" valign="middle"><font><%=movie.getCategoryName()%></font></td>
                <td style=" background-color: #cc6666;" valign="middle"><font><%=movie.getDateActive()%> <%=movie.getTimeActive()%></font></td>
                <td style=" background-color: #cc6666;" valign="middle"><font>P<%=movie.getPrice()%></font></td>
                <td style=" background-color: #cc6666;" valign="middle"><font><%=movie.getReleaseDate()%></font></td>
                <td style=" background-color: #cc6666;" valign="middle"><font><%=movie.getViews()%></font></td>
                <td style=" background-color: #cc6666;" valign="middle"><font><%=movie.getRating()%></font></td>
                <td style=" background-color: #cc6666;" valign="middle"><font><%=movie.getActive()%></font></td>
                
                <td style=" background-color: #cc6666;" valign="middle"><div id="editmovie<%=movie.getId()%>"><font><a href="javascript:gotoEditMovie(<%=movie.getId()%>)">Edit</a></font></div></td>
                <td style=" background-color: #cc6666;" valign="middle"><div id="restoremovie<%=movie.getId()%>"><font><a href="javascript:restoreMovie(<%=movie.getId()%>)">Restore</a></font></div></td>
                        
                
                
                
                
                <%
                
                
                    }
            %>
            </tr>
            <%
            i++;
        }
        
    }
%>